﻿Public Class JugarParejas
    Private nuevoJuego As New InicializarParejas()
    Private _NumClick As Integer
    Public Property NumClick As Integer
        Get
            Return _NumClick
        End Get
        Set(value As Integer)
            _NumClick = value
        End Set
    End Property
    Public Sub New()
        NumClick = 0
    End Sub
    Public Event DosClick(ByVal num As Integer)
    Public Sub destapar(pic As PictureBox, num As Integer)
        pic.Image = Image.FromFile(My.Application.Info.DirectoryPath & "\parejas" & num + 1 & ".png")
        'pic.Image = frmParejas.imlImagenes.Images(num)
    End Sub
    Public Sub tapar(ByRef pic1 As PictureBox, ByVal pic2 As PictureBox)
        pic1.Enabled = True
        pic2.Enabled = True
        pic1.Image = Nothing
        pic2.Image = Nothing

    End Sub
    Public Function encontrado(pic1 As PictureBox, pic2 As PictureBox) As Boolean
        Return nombrar(pic1) = nombrar(pic2)
    End Function
    Public Function nombrar(pic As PictureBox) As Integer
        Select Case nuevoJuego.Cargador(pic.Tag)
            Case 0, 1
                Return 0
            Case 2, 3
                Return 1
            Case 4, 5
                Return 2
            Case 6, 7
                Return 3
            Case 8, 9
                Return 4
            Case 10, 11
                Return 5
            Case 12, 13
                Return 6
            Case 14, 15
                Return 7
            Case 16, 17
                Return 8
            Case 18, 19
                Return 9
            Case 20, 21
                Return 10
            Case 22, 23
                Return 11
            Case Else : Return -1
        End Select
    End Function
    Public Sub sumarClick()
        Me.numClick = NumClick + 1
        If NumClick = 2 Then
            RaiseEvent DosClick(NumClick)
        End If
    End Sub
    Public Sub restablecerClick()
        NumClick = 0
    End Sub
End Class
